window.onload=function(){
//  $.cookie('ldd','ldd');
//  alert(1); return false;
    get_Ajax();
//     $.ajax({
//         type:"get",
//         url:"http://localhost/old/TP5/public/index.php/index/Index/index",
//         dataType:"jsonp",
//         jsonp:"callback",
//         success:function(msg){
            
// //          circle = $('#circle').attr('class');
// //          var circle = circle.substring(20,22);
//             var str="";
//             $.each(msg.data, function(k,v) {
//                 str+="<div class='index-pad'> <a class='index-list index-che' id='dd' name='"+v.productId+"' href='javascript:;'>\
//                 <div class='list-tit clear'> <span class='fl tit-name'><i></i><strong>HBSF-FFFO-0021</strong></span> <span class='fr tit-site'><i></i> <strong>"+v.productName+"</strong> </span> </div>\
//                 <div class='list-main'>\
//                  <div class='main-l'> <span class='per'>"+v.interestRate+"<i>%</i></span> <span class='add'>A</span> </div>\
//                <div class='main-m main-m-1'> <span>"+v.totalSum+"<i>万</i></span> </div>\
//                 <div class='main-m main-m-2'> <span class='day'>"+v.deadLine+"<i>天</i></span> </div>\
//                 <div class='main-r'> <span class='circle-blue circle-c0'></span> <span class='val-per'>0<i>%</i></span> </div>\
//                 </div>\
//                 </a> </div>";

//             });
//             $(".index-list-wrap").html(str);
            
//         },
//         error:function(){
//             alert(222);
//         }
     
//     })
         
}
$(document).on('click','.UpPage a',function(){
    var np=$('#np').html();
    var sp=$('#sp').html();
    var go=$(this).attr('name');
    if(go=='last'){
      if(parseInt(np)>1){
        get_Ajax('product',parseInt(np)-1,5,'one4');
      }else{
        alert('亲！已经是第一页了');return false;
      }
    }else{
      // alert(np+sp)
      if(parseInt(sp)-parseInt(np)){
        get_Ajax('product',parseInt(np)+1,5,'one4');
      }else{
        alert('亲！已经是最后一页了');return false;
      }
    }
  })
function get_Ajax(table='product',page=1,size=5,name='one4'){
    // alert(1)
    $.ajax({
      type:"get",
      url:"http://47.93.21.169/old/TP5/public/index.php/index/product/productList",
      dataType:'JSONP',
      data:{"table":table,"page":page,"size":size,"name":name},
      jsonp:'callback',
      success:function(e){
        console.log(e);
        var str='';
        $.each(e.data,function(k,v){
          str+='<div class="index-pad" name="'+v.productId+'"> <a class="index-list index-che" onClick="infor('+v.productId+')" href="javascript:void(0)"><div class="list-tit clear"> <span class="fl tit-name"><i></i>';
          str+='<strong>'+v.productName+'</strong></span> <span class="fr tit-site"><i></i> ';
          str+='<strong>内蒙古锡林格勒蒙古 </strong> </span> </div><div class="list-main"><div class="main-l">';
          str+=' <span class="per">'+v.interestRate*100+'<i>%</i></span>  <span class="add">A</span> </div><div class="main-m main-m-1"> ';
          str+='<span>'+v.totalSum/10000+'<i>万</i></span> </div><div class="main-m main-m-2"> <span class="day">';
          if(v.deadLine=='2'){
            str+=3*30;
          }else if(v.deadLine=='5'){
            str+=6*30;
          }else if(v.deadLine=='11'){
            str+=12*30;
          }
          if(v.bi=='a'){
            str+='<i>天</i></span> </div><div class="main-r"> <span class="circle-gray"></span> <span class="val-txt">即将上线</span> </div></div></a></div>';
          }else if(v.bi=='b'){
            str+='<i>天</i></span> </div><div class="main-r"> <span class="circle-gray"></span> <span class="val-txt">回款中</span> </div></div></a></div>';
          }else if(v.bi=='c'){
            str+='<i>天</i></span> </div><div class="main-r"> <span class="circle-gray"></span> <span class="val-txt">已结束</span> </div></div></a></div>';
          }else{
            str+='<i>天</i></span> </div><div class="main-r"> <span class="circle-blue circle-c'+v.bi+'"></span> <span class="val-per">'+v.bi+'<i>%</i></span> </div></div></a></div>';
          }
        })
      var last = e.page-1>0?e.page-1>0:1;
       var next = e.page+1>e.page_tota?e.page_tota:e.page+1;
        $('.UpPage').html(' <ul> <li><a href="javascript:void(0)" name="last">上一页</a></li><li><span><font id="np">'+e.page+'</font>/<font id="sp">'+e.page_total+'</font></span></li><li><a href="javascript:void(0)" name="next">下一页</a></li></ul>');
        $('.index-list-wrap').html(str); 
      }
    })
  }






